﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Block : MonoBehaviour {
    public MoveObj.ObjType m_ObjType;
    public Image m_Image;
    public int m_Row, m_Column;
    public bool m_IsMoving;
    public bool m_IsHighLight;
    public List<Color> m_ColorList = new List<Color>();
    [SerializeField]
    private Color m_initColor;
	// Use this for initialization
	void Awake () {
        m_initColor = m_Image.color;

    }
	
	// Update is called once per frame
	void Update () {
		
	}
    public void HighLight(MoveObj.ObjType type) {
        m_ObjType = type;
        Color color1 = new Color();
        switch (m_ObjType) {
            case MoveObj.ObjType.White:
                color1 = m_ColorList[0];
                break;
            case MoveObj.ObjType.Blue:
                color1 = m_ColorList[1];
                break;
            case MoveObj.ObjType.Orange:
                color1 = m_ColorList[2];
                break;
            case MoveObj.ObjType.Yellow:
                color1 = m_ColorList[3];
                break;
            case MoveObj.ObjType.Green:
                color1= m_ColorList[4];
                break;
            case MoveObj.ObjType.Purple:
                color1 = m_ColorList[5];
                break;
            case MoveObj.ObjType.Red:
                color1 = m_ColorList[6];
                break;
            case MoveObj.ObjType.Black:
                color1 = Color.black;
                
                break;
        }
        m_Image.color = new Color(color1.r,color1.g,color1.b,1f);
        m_IsHighLight = true;
    }
    public void DeLight() {
        m_Image.color = m_initColor;
        m_IsHighLight = false;
        m_IsMoving = false;
        m_ObjType = MoveObj.ObjType.Init;
    }
    public void Fall1(int fallcount) {
        GameMgr.s_Instance.DeLightByPos(m_Row, m_Column);
    }
    public void Fall2(int fallcount,MoveObj.ObjType type) {
        GameMgr.s_Instance.HighLightByPos(m_Row + fallcount, m_Column, type);
    }
    public void Translation1(int count) {
        GameMgr.s_Instance.DeLightByPos(m_Row, m_Column);
    }
    public void Translation2(int count, MoveObj.ObjType type) {
        GameMgr.s_Instance.HighLightByPos(m_Row, m_Column + count, type);
    }
}
